<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8" />
	<title>书店管理系统</title>
	<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
	<link rel="stylesheet" type="text/css" href="/public/css/bootstrap.min.css" />
	<link rel="stylesheet" type="text/css" href="/public/css/swiper.min.css" />
	<link href="http://cdn.bootcss.com/animate.css/3.5.2/animate.min.css" rel="stylesheet" media="all">
	<link href="/public/css/bootstrap-touch-slider.css" rel="stylesheet" media="all">
	<link rel="stylesheet" type="text/css" href="/public/css/pc.css" />
	<link rel="stylesheet" type="text/css" media="screen and (max-width:1200px)" href="/public/css/ipad.css">
	<link rel="stylesheet" type="text/css" media="screen and (max-width:768px)" href="/public/css/phone.css">
	<script type="text/javascript" src="/public/js/jquery-1.11.1.min.js"></script>
	<script type="text/javascript" src="/public/js/bootstrap.min.js"></script>
	<script type="text/javascript" src="/public/js/swiper.min.js"></script>
	<script type="text/javascript" src="/public/js/scrollReveal.js"></script>
	<script src="http://cdn.bootcss.com/jquery.touchswipe/1.6.18/jquery.touchSwipe.min.js"></script>
	<script src="/public/js/bootstrap-touch-slider-min.js"></script>
	<script type="text/javascript" src="http://api.map.baidu.com/api?v=2.0&ak=Diy1GpUowSnG4kyw93KWvG4GfQDm3xch"></script>

	<!-- 地区插件 -->
	<script src="/public/js/distpicker.data.js"></script>	
	<script src="/public/js/distpicker.js"></script>
	<script src="/public/js/main.js"></script>	

	<script type="text/javascript" src="/public/js/jquery.cookie.js"></script>
	<script type="text/javascript" src="/public/js/base64.js"></script>
	<script type="text/javascript" src="/public/js/xiuzhen.js"></script>
	<script>
		if ($(document.body).width() < 760) {
			document.documentElement.style.fontSize = document.documentElement.clientWidth / 7.5 + 'px';
		} else {
			document.documentElement.style.fontSize = document.documentElement.clientWidth / 1 + 'px';
		}
	</script>
	<!--兼容ie8-->
	<!--[if lt IE 9]>
	    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
	    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>
	<!-- 头部导航开始 -->
	<div class="header">
		<div class="nav">
			<img class="logo" src="/public/images/logo.png" alt="">
			<ul class="top">
				<li>
					<a href="index.html">首页</a>
				</li>
				<li>
					<a href="box.html">图书展示</a>
				</li>
				<li>
					<a href="labOne.html">图书资讯</a>
					
				</li>
				
				<li>
					<a href="about.html">关于我们</a>
				</li>
				<li>
					<a href="contact.html">联系我们</a>
				</li>
			</ul>
			<div class="right">
				<a href="login.html" class="login">会员登陆</a>
				
				
				<a class="indexCart" href="cart.html">
					<img class="cart" src="/public/images/cart.png" alt="">
				</a>
				<a class="leaguer" href="member.html" style="display: none;">
					<img class="" src="/public/images/people2.png" alt="">
				</a>
				<p id="username" style="display: none;"></p>
				<!-- <p class="line"></p>
				<img class="weixin" src="images/weixin.png" alt=""> -->
			</div>
		</div>
	</div>
	
	<!-- 子页面位置公共样式 -->
	<div class="com-position member-position">
		<p class="container">
			<span>当前页面：</span>
			<a href="javascript:;">首页</a> >
			<a href="javascript:;">会员中心</a>
		</p>
	</div>

	<!-- 个人中心页面 -->
	<div class="member">
		<div class="container">
			<div class="left">
				<div class="head">
					<p class="china">会员中心</p>
					<p class="eng">Member Center</p>
				</div>
				<ul class="menu">
					<li><a href="member.html">我的个人资料</a></li>	
					<li><a href="order.html">我的订单</a></li>
					<li><a href="saleOrder.html">我的代售</a></li>
					<li><a href="address.html" class="active">我的收货地址</a></li>
					<li><a href="editPassword.html">修改密码</a></li>
					<li class="loginOut"><a href="javascript:;">退出</a></li>
				</ul>
			</div>
			<div class="right">
				<div class="title">添加新地址</div>
				<form action="" id="addAddress">
					<input type="text" hidden name="userId" class="userId">
					<input type="text" hidden value="0" class="addressId" name="addressId">
					<div class="addAddress">
						<div class="item ">
							<p>姓名</p>
							<input type="text" name="reciverName" class="form-control name reciverName" placeholder="">
						</div>
						<div class="item seat">
							<p>所在地</p>
							<div data-toggle="distpicker" class="distpicker">
								<select id="province" class="form-control" name="province"></select>
								<select id="city" class="form-control" name="city"></select>
								<select id="district" class="form-control" name="district"></select>
							</div>
						</div>
						<div class="item">
							<p>详细地址</p>
							<input type="text" name="detailAddress" class="form-control detail detailAddress" placeholder="">
						</div>
						<div class="item code">
							<p>邮编</p>
							<input type="number" name="zipCode" class="form-control zipCode" placeholder="">
						</div>
						<div class="item code">
							<p>手机或固定电话</p>
							<input type="number" name="phoneNumber" class="form-control phoneNumber" placeholder="">
						</div>
						<div class="item">
							<a href="javascript:;" class="hold">保存</a>
						</div>
					</div>
				</form>
				
			</div>
		</div>
	</div>

	<!-- 预约弹框样式 -->
	<div class="appointShadow"></div>


	<!-- 右侧弹框 -->
	<div class="rightFrame">
		<div class="bespoke"><a href="saleApply.html">代售申请</a></div>
		<div class="placement"><img src="/public/images/top.png" alt="">置顶</div>
	</div>

	<!-- 弹框样式 -->
	<div class="alert-box">
		<span class="xz-alert alert alert-danger"></span>
	</div>

	<!-- 公共底部开始 -->
	<div class="footer">
		<div class="footer-content1">
			<div></div>
		</div>
		<div class="footer-content">
			<div class="container">
				<div class="content">
					<div class="left">
						<img class="bottom-logo" src="/public/images/logo.png" alt="">
						<p class="des">此网站为不仅为人们提供了便利的购书平台，还在此基础上增加了代售和出租的功能，人们有想卖的书籍可以在此平台申请，平台会帮忙代售，还有的宝宝们，不想购买书籍，此平台提供了租书的功能，不需要购买就可以便宜看到自己想看的书籍啦！！！</p>
					</div>
					<div class="right">
						<div class="contact">
							<p class="title">联系我们</p>
							<p class="phone">电话：0755-23324516</p>
							<p class="email">邮箱：cd.01@oil-com.com</p>
							<p class="email">QQ：1056598469</p>
						</div>
					</div>
				</div>
				<p class="copy">地址：山西省太原市万柏林区下元街道公园时代城2号楼1301</p><br>
			</div>
		</div>	
		
	</div>

	<script type="text/javascript">
	
		if(!$.cookie('uid')){
			location.href = './index.html';
		}

		var loginUrl = Base64.encode("add_address.html");  
		$('.header .nav .right .login').attr('href','./login.html?loginurl='+loginUrl); 

		// 首页banner
		$('#bootstrap-touch-slider').bsTouchSlider();
		

		// 点击返回顶部
		$('.rightFrame .placement').on('click', function () {
			$("html,body").animate({
				scrollTop: 0
			}, 1000);
		});


		// 获取头部参数
		function parseUrl(url) {
			url = decodeURI(url)
			var splitURL = url.split('?')
			if (splitURL[0] == url) return {}
			var parmsStr = splitURL[1]
			var parms = parmsStr.split('&')
			var result = {}
			for (var i = 0; i < parms.length; i++) {
				var key = parms[i].split('=')[0]
				var value = Number(parms[i].split('=')[1]) || parms[i].split('=')[1]
				result[key] = value
			}
			return result
		}
		var addressId =  parseUrl(window.location.href).addressId;
		var comfirmTag = parseUrl(window.location.href).comfirmTag;
		if(addressId){
			$(".addressId").val(addressId);
		}
		if(addressId){
			$.ajax({
                type: "get",
                dataType: "", // submit info
                url: url + '/v1/front/mall/address/'+ addressId,
                success: function (res) {
                    if (!res.resultStatus) {
                        $(".xz-alert").html(res.errorMessage);
                        $('.xz-alert').show();
                        setTimeout(function () {
                            $(".xz-alert").hide();
                        }, 3000);
                        return
					}
					
					$('.distpicker').distpicker('destroy');
					$('.distpicker').distpicker({
					  province: res.resultData.province,
					  city: res.resultData.city,
					  district: res.resultData.district
					});
					$(".detailAddress").val(res.resultData.detailAddress);
					$(".phoneNumber").val(res.resultData.phoneNumber);
					$(".reciverName").val(res.resultData.reciverName);
					$(".zipCode").val(res.resultData.zipCode);
						
                },
                error: function (e) {
                    $(".xz-alert").html("请求数据失败");
                    $('.xz-alert').show();
                    setTimeout(function () {
                        $(".xz-alert").hide();
                    }, 3000);
				}
			})
		}

		// 添加地址
		$(".userId").val($.cookie('uid'));
		$("#addAddress .hold").on("click",function(){
			if($("#addAddress .reciverName").val() == ""){
				$(".xz-alert").html("姓名不能为空!");
				$('.xz-alert').show();
				setTimeout(function () {
					$(".xz-alert").hide();
				}, 2000);
			}else if($("#addAddress .detailAddress").val() == ""){
				$(".xz-alert").html("详细地址不能为空!");
				$('.xz-alert').show();
				setTimeout(function () {
					$(".xz-alert").hide();
				}, 2000);
			}else if($("#addAddress .phoneNumber").val() == ""){
				$(".xz-alert").html("联系方式不能为空!");
				$('.xz-alert').show();
				setTimeout(function () {
					$(".xz-alert").hide();
				}, 2000);
			}else{
				$.ajax({
					type: "post",
					dataType: "json", // submit info
					url: url + '/v1/front/mall/address',
					data:$("#addAddress").serializeArray(),
					contentType:"application/x-www-form-urlencoded",
					success: function (res) {
						if (!res.resultStatus) {
							$(".xz-alert").html(res.errorMessage);
							$('.xz-alert').show();
							setTimeout(function () {
								$(".xz-alert").hide();
							}, 2000);
							return
						}
						$(".xz-alert").html("提交成功！");
						$('.xz-alert').show();
						setTimeout(function () {
							$(".xz-alert").hide();
							if(comfirmTag){
								location.href = './confirm.html?addressId='+res.resultData;
							}else{
								location.href = './address.html';
							}
						}, 2000);
						
					},
					error: function (e) {
						$(".xz-alert").html("提交数据失败");
						$('.xz-alert').show();
						setTimeout(function () {
							$(".xz-alert").hide();
						}, 2000);
					}
			
				})
			}
			
		})
	</script>		

</body>

</html>